VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "clsMqGlobal"
Attribute VB_GlobalNameSpace = True
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit

Private blnValidMqSettings As Boolean

Private mblnMqEnabled As Boolean
Private mstrMqType As String
Private mstrRqstKey As String
Private mstrUddSystemIndicator As String

Private mblnConnectedToDb As Boolean
Private mstrCallingProgram As String
Public Property Let CallingProgram(vdata As String)
    mstrCallingProgram = vdata
End Property
Public Property Get CallingProgram() As String
    CallingProgram = mstrCallingProgram
End Property

Public Property Let ConnectedToDb(vdata As Boolean)
    mblnConnectedToDb = vdata
End Property
Public Property Get ConnectedToDb() As Boolean
    ConnectedToDb = mblnConnectedToDb
End Property




Public Property Get MqEnabled() As Boolean
    MqEnabled = mblnMqEnabled
End Property


Public Function TokenizeReturn(ByVal mqReturn As String, _
                                strIndicator As String, _
                                PolicyNo As String, _
                                UACFID As String, _
                                BranchCode As String, _
                                BranchName As String, _
                                RegionCode As String, _
                                RegionName As String, _
                                PortfolioCode As String, _
                                PortfolioName As String)
                         
    'This function is only used for the UDD MQ routine to determine the policy no details
    'found on mainframe
                         
    Dim Pos As Double
    Dim PosSp As Double
    Dim PosNull As Double
    Dim dblLen As Double
    'Dim X(8) As String
    Dim X(12) As String
    ReDim Y(0) As String
    Dim i As Integer
    Dim j As Integer
    Dim k As Integer
    Dim l As Integer
    Dim strBuffer As String
    Dim strElement As String
    Dim strQueue As String
    Dim bUnique As Boolean
        
    ' Remove trailing nulls
    If mqReturn = "" Then
        Exit Function
    End If
    PosNull = InStr(1, mqReturn, Chr(0))
    If PosNull <> 0 Then
      mqReturn = Left(mqReturn, PosNull - 1)
    End If
    
    ' Remove double spaces and nulls
    strBuffer = ""
    Do While Len(mqReturn) > 0
      If Left(mqReturn, 1) = " " Then
        If Right(strBuffer, 1) <> " " Then
          strBuffer = strBuffer & Left(mqReturn, 1)
        End If
      ElseIf Left(mqReturn, 1) <> Chr(0) Then
        strBuffer = strBuffer & Left(mqReturn, 1)
      End If
      mqReturn = Right(mqReturn, Len(mqReturn) - 1)
    Loop
        
    ' Remove trailing space
    If Right(strBuffer, 1) = " " Then
      strBuffer = Left(strBuffer, Len(strBuffer) - 1)
    End If

    ' Tokenise
    i = 0
    Do While Len(strBuffer) > 0
        'SEPARATING VALUES BETWEEN COMMAS
        Pos = InStr(1, strBuffer, ",")
        If Pos <> 0 Then
            X(i) = Left(strBuffer, Pos - 1)
        Else
            X(i) = strBuffer
            strBuffer = ""
        End If
        strBuffer = Mid(strBuffer, Pos + 1)
        X(i) = Trim(X(i))
        
        'barb:still to update this in Auto_check TokenizeReturn
        If X(i) <> "" Then
            ' Tokenise array element
            strElement = X(i)
            j = 0
            Do While Len(strElement) > 0
              ' Check for spaces
              PosSp = InStr(strElement, " ")
              ReDim Preserve Y(j)
              If PosSp <> 0 Then
                  Y(j) = Left(strElement, PosSp - 1)
              Else
                  Y(j) = strElement
                  strElement = ""
              End If
              strElement = Mid(strElement, PosSp + 1)
              j = j + 1
            Loop
        
            X(i) = ""
            For k = 0 To UBound(Y)
              bUnique = True
              For l = 0 To (k - 1)
                If Y(l) = Y(k) Then
                  bUnique = False
                  l = k
                End If
              Next l
              If bUnique Then
                If k = 0 Then
                  X(i) = Y(k)
                Else
                  X(i) = X(i) & " " & Y(k)
                End If
              End If
            Next k
        End If
        
        i = i + 1
    
    Loop
                         
    strIndicator = X(0)
    PolicyNo = CStr(CDbl(X(1)))
    UACFID = X(2)
    
    'Update Branch Master table
    BranchCode = X(3)
    BranchName = X(4)
    If BranchCode <> "" Then
      'UpdateBranches BranchCode, BranchName
    End If
        
    'Update Region Master table
    RegionCode = X(5)
    RegionName = X(6)
    If RegionCode <> "" Then
      'UpdateRegions RegionCode, RegionName
    End If
        
    'Update Portfolio Master table
    PortfolioCode = X(7)
    PortfolioName = X(8)
    If PortfolioCode <> "" Then
      'UpdatePortfolios PortfolioCode, PortfolioName
    End If
        
End Function


